package IOBaseTest;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Created by yexuan on 2018/3/12.
 */
public class BufferedWriterDemo {
    public static void main(String[] args) throws IOException {
        FileWriter fw = new FileWriter("buff.txt");

        //为了提高字符写入流效率，加入了缓冲技术
        BufferedWriter bufw = new BufferedWriter(fw);

        for (int i = 0; i < 3; i++) {
            bufw.write("hello world!"+i);
            bufw.newLine();  //适合于各平台的换行
            bufw.flush();
        }

        //关闭缓冲区，就是在关闭缓冲区中的流对象
        bufw.close();
    }
}
